<?php

namespace App\Model\BbcModel;

use Service\Code\Normal;
use App\Model\BaseModel\BaseBbcModel;

/**
 * 户实名认证
 */
class MemberCertification extends BaseBbcModel {

    public $table = 'ly_member_certification';

    /**
     * 是否申请了审核
     * @param array $param
     * @return   array
     */
    public static function check($param) {
        if (!empty($param['mid'])) {
            $member = Member::where('mid' ,$param['mid'])->count();
        } else {
            if (empty($param['mobile'])) {
                return Normal::returnCode(Normal::SUC, '查询成功', ['isCheck' => 0]);
            }
            $member = Member::where('account' ,$param['mobile'])->count();
        }
        if (empty($member)) {
            return Normal::returnCode(Normal::SUC, '查询成功', ['isCheck' => 0]);
        }
        $mnUser = Mnuser::where('mid', $param['mid'])->where('mnid', 2)->count();
        if ($mnUser) {
            return Normal::returnCode(Normal::SUC, '查询成功', ['isCheck' => 1]);
        }
        $cInfo = self::where("mid", $param['mid'])->whereIn('status', [0, 1])->where('type', 1)->select(['status'])->first();
        if ($cInfo) {
            return Normal::returnCode(Normal::SUC, '查询成功', ['isCheck' => $cInfo->status == 1 ? 1 : 2]);
        }
        return Normal::returnCode(Normal::SUC, '查询成功', ['isCheck' => 0]);
    }
}